﻿using CommonModule;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Demo
{
    public partial class MainForm : Form
    {
        private TCPSetting tcp;
        private AutoFit autoFit;
        private ParamerSetting paramerSetting;
        private MultiFit multiFit;
        private PositionCorrection positionCorrection;
        public MainForm()
        {
            InitializeComponent();
            Global.Instance.Initialize();
            Initialize();
        }

        private void Initialize()
        {
            tcp = new TCPSetting();
            autoFit = new AutoFit();
            paramerSetting = new ParamerSetting();
            multiFit = new MultiFit();
            positionCorrection = new PositionCorrection();
          
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        #region 绑定窗体，动态加载
        private void btn_TCPSetting_Click(object sender, EventArgs e)
        {
            BindForm(tcp);
        }
        /// <summary>
        /// 绑定窗体
        /// </summary>
        /// <param name="ob"></param>
        private void BindForm(object ob)
        {
            if (ob != null)
            {
                panel_Form.Controls.Clear();//清空Panel的绑定
                Form temp = ob as Form;
                temp.TopLevel = false;
                temp.Parent = panel_Form;
                temp.Show();
            }
        }

        private void btn_ParamerSetting_Click(object sender, EventArgs e)
        {
            BindForm(paramerSetting);
        }

        private void btn_AutoFit_Click(object sender, EventArgs e)
        {
            BindForm(autoFit);
        }

        private void btn_MultiFit_Click(object sender, EventArgs e)
        {
            BindForm(multiFit);
        }

        private void btn_PositionCorrection_Click(object sender, EventArgs e)
        {
            BindForm(positionCorrection);
        }
        #endregion
    }

}
